package tt.dz.egobus.servicemanager.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tt.dz.egobus.servicemanager.entities.DriverRegisterBusRelative;
import tt.dz.egobus.servicemanager.service.GrabDriverRegisterBusRelativeService;

import java.util.List;

/**
 * @author Anson
 * @date 17-8-16
 * @name
 * @since 1.0.6
 */
@Service("grabDriverRegisterBusRelativeServiceImpl")
public class GrabDriverRegisterBusRelativeServiceImpl extends DriverRegisterBusRelativeServiceImpl
        implements GrabDriverRegisterBusRelativeService {


    @Override
    @Transactional
    public boolean doBusinessGrab(DriverRegisterBusRelative relative) {
        relative.setAbleGrabBusiness();
        try {
            this.dao.update(relative);
        } catch (Exception e) {
            return false;
        }
        return true;
    }

    @Override
    @Transactional
    public boolean giveUpDriverBusinessGrab(DriverRegisterBusRelative relative) {
        relative.setAbleActive();
        try {
            this.dao.update(relative);
        } catch (Exception e) {
            return false;
        }
        return true;
    }

    @Transactional
    @Override
    public boolean doBespeakGrabBusinessSuccess(DriverRegisterBusRelative relative) {
        relative.setAbleActive();
        try {
            this.dao.update(relative);
        } catch (Exception e) {
            return false;
        }
        return true;
    }

    @Override
    @Transactional
    public boolean driverCancelBusiness(DriverRegisterBusRelative relative) {
        relative.setAbleActive();
        try {
            this.dao.update(relative);
        } catch (Exception e) {
            return false;
        }
        return true;
    }

    @Override
    @Transactional
    public int terminalBusinessDriverStatus(List<String> needHandlerDriverDbStatusActive) {
        try {
            return this.dao.terminalBusinessDriverStatus(needHandlerDriverDbStatusActive);
        } catch (Exception e) {
        }
        return 0;
    }
}
